﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GeneratorLib
{
    public class CodeBuilder
    {
        private StringBuilder sb = new StringBuilder();
        public CodeBuilder()
        {
            sb.Clear();
        }

        public void Clear()
        {
            sb.Clear();
        }

        public void Append(string text)
        {
            sb.Append(text);
        }

        public void AppendLine()
        {
            sb.AppendLine();
        }
        public void AppendLine(string text)
        {
            sb.AppendLine(text.Replace("{{", "{").Replace("}}", "}"));
        }

        public void AppendLine(string format, object arg0)
        {
            sb.AppendLine(string.Format(format, arg0).Replace("{{", "{").Replace("}}", "}"));
        }

        public void AppendLine(string format, object arg0, object arg1)
        {
            sb.AppendLine(string.Format(format, arg0, arg1).Replace("{{", "{").Replace("}}", "}"));
        }
        public void AppendLine(string format, object arg0, object arg1, object arg2)
        {
            sb.AppendLine(string.Format(format, arg0, arg1, arg2).Replace("{{", "{").Replace("}}", "}"));
        }
        //public void AppendLine(string format, object arg0, object arg1, object arg2, object arg3)
        //{
        //    sb.AppendLine(string.Format(format, arg0, arg1, arg2,arg3).Replace("{{", "{").Replace("}}", "}"));
        //}

        public void AppendLine(string format, params object[] args)
        {
            sb.AppendLine(string.Format(format, args).Replace("{{", "{").Replace("}}", "}"));
        }

        public override string ToString()
        {
            return sb.ToString();
        }
    }
}
